import axios from 'axios';


let host = 'http://127.0.0.1:8000';

//获取导航栏
export const getLevel = params => {
    return axios.get(`${host}/first1`, params, {
        headers: {
            'X-CSRF-TOKEN': document.querySelector('meta[name="csrf-token"]').getAttribute('content')
        }
    })
}

//查询一级标题
export const getFirstLevel = params => {
    return axios.get(`${host}/first`, params, {
        headers: {
            'X-CSRF-TOKEN': document.querySelector('meta[name="csrf-token"]').getAttribute('content')
        }
    })
}

//查询单个一级标题
export const showFirstLevel = params => {
    return axios.get(`${host}/first/` + params, {
        headers: {
            'X-CSRF-TOKEN': document.querySelector('meta[name="csrf-token"]').getAttribute('content')
        }
    })
}

//添加一级标题
export const addFirstLevel = params => {
    return axios.post(`${host}/first`, params, {
        headers: {
            'X-CSRF-TOKEN': document.querySelector('meta[name="csrf-token"]').getAttribute('content')
        }
    })
}

//删除一级标题
export const RemoveFirstLevel = params => {
    return axios.delete(`${host}/first/` + params, {
        headers: {
            'X-CSRF-TOKEN': document.querySelector('meta[name="csrf-token"]').getAttribute('content')
        }
    })
}

//获取二级标题
export const getSecondLevel = params => {
    return axios.get(`${host}/second/` + params, {
        headers: {
            'X-CSRF-TOKEN': document.querySelector('meta[name="csrf-token"]').getAttribute('content')
        }
    })
}

//添加二级标题
export const addSecondLevel = params => {
    return axios.post(`${host}/second`, params, {
        headers: {
            'X-CSRF-TOKEN': document.querySelector('meta[name="csrf-token"]').getAttribute('content')
        }
    })
}
//查找单个二级标题
export const showSecondLevel = params => {
    return axios.get(`${host}/second1/` + params, {
        headers: {
            'X-CSRF-TOKEN': document.querySelector('meta[name="csrf-token"]').getAttribute('content')
        }
    })
}

//更新二级标题
export const updateSecondLevel = params => {
    return axios.post(`${host}/second1/`, params, {
        headers: {
            'X-CSRF-TOKEN': document.querySelector('meta[name="csrf-token"]').getAttribute('content')
        }
    })
}

//删除二级标题
export const RemoveSecondLevel = params => {
    return axios.delete(`${host}/second/` + params, {
        headers: {
            'X-CSRF-TOKEN': document.querySelector('meta[name="csrf-token"]').getAttribute('content')
        }
    })
}

//跳转页面
export const skipPage = (url, params) => {
    return axios.get(`${host}/` + url + '?page=' + params, {
        headers: {
            'X-CSRF-TOKEN': document.querySelector('meta[name="csrf-token"]').getAttribute('content')
        }
    })
}
